<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>我的订单</title>
    <link href="__INDEX__/css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
    <link rel="stylesheet" href="__INDEX__/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/yund.css" />
</head>

<body>
		
	<div class="mui-content">
		<ul class="myord_nav clearfix">
	    	<li {if !$status}class="active"{/if}><a href="{:url('member/orders')}">全部</a></li>
	    	<li {if $status==1}class="active"{/if}><a href="{:url('member/orders',['status'=>1])}">待付款</a></li>
	    	<li {if $status==2}class="active"{/if}><a href="{:url('member/orders',['status'=>2])}">待发货</a></li>
	    	<li {if $status==3}class="active"{/if}><a href="{:url('member/orders',['status'=>3])}">待收货</a></li>
	    	<li {if $status==4}class="active"{/if}><a href="{:url('member/orders',['status'=>4])}">待评价</a></li>
	    </ul>
		<div class="order_listbox">
			{if $order_list==null}
			<p id="no_record" style="color:#D6AA50;text-align: center;">订单为空</p>
			{/if}
			{volist name='order_list' id='order_info'}
			<div class="order_item" id='order_detail' onclick="to_detail('{$order_info.order_id}')">
				
				<div class="order_zt clearfix" style="height: 30px;line-height: 30px;">
					<div class="left" style="width: 60%;">订单编号：{$order_info.order_sn}
					</div><div class="right" style="margin-right: 10px;">
						{:get_order_type($order_info['status'])}
					</div>
				</div>
				<ul class="order_item_list">
					{volist name="$order_info.order_item" id="order_item"}
					<li>
						<div class="order_item_spimg"><img src="{$order_item['thumb']}" style="min-height: 6.5rem;min-width: 6.5rem;"></div>
						<div class="order_item_spinfo">
							<div class="order_itspnam">{$order_item['goods_name']}</div>
							<div class="order_isp_b clearfix">
								<span class="ord_pribox">
									<em class="pri">¥{$order_item['price']}</em>
								</span>
								<span class="pay_spnum">X{$order_item['nums']}</span>
							</div>
							<div class="order_isp_b clearfix">
								{if $order_info.status===4}
								<div class="order_item_btnbox clearfix" style="padding: 0px;border-top:0px">
									<a href="{:url('shop/order_comment',['order_id'=>$order_info['order_id'],'goods_id'=>$order_item['goods_id']])}" >评价</a>
								</div>
								{/if}
							</div>
						</div>
					</li>
					{/volist}
				</ul>
				<div class="order_item_zj">
					<span>共{:count($order_info.order_item)}件商品</span>
					<span class="jiag">合计：<em>¥{$order_info.pay_price}</em></span>
					<!--<span class="yunf">(含运费¥0.00)</span>-->
				</div>
			</div>
			{if $order_info.status===1}
			<div class="order_item_btnbox clearfix" style="background-color: #fff;">
				<a href="javascript:void(0)" onclick="cancel_pay('{$order_info.order_id}')">取消订单</a>
				{if $order_info.user_id==$Think.session.user_id}
				<a href="{:url('index/querdd',['order_id'=>$order_info.order_id])}" class="order_fkbtn">付款</a>	
				{/if}
			</div>
			{/if}
			{if $order_info.status===2&&$Think.session.user_info.is_pt==1}
			<div class="order_item_btnbox clearfix" style="background-color: #fff;">
				<a href="javascript:void(0)" onclick="fahuo('{$order_info.order_id}',this)">发货</a>
			</div>
			{/if}
			{if $order_info.status===3}
			<div class="order_item_btnbox clearfix" style="background-color: #fff;">
				{if $order_info.user_id==$Think.session.user_id}
				<a href="javascript:void(0)" onclick="take_order('{$order_info.order_id}')">确认收货</a>
				{/if}
			</div>
			{/if}
			{/volist}
		</div>
	{include file="public/bottom" /}
	</div>
</body>
</html>
{include file="public/footer" /}
<script>
	function cancel_pay(id){
		layer.confirm('您确定取消订单？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type:"post",
				url: "{:url('member/cancel_order')}",
				data: {order_id : id},//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.reload();
						  }
					}); 
				}
			})
		})
	}
	
	function fahuo(id,obj){
		 layer.prompt({title: '请输入发货物流号', formType: 3}, function(val, index){
		 		if(val==""){
		 			alert("请输入物流号!");
		 			return;
		 		}
		 		$.ajax({
					type:"post",
					url: "{:url('member/fahuo')}",
					data: {order_id : id,no:val},//表单数据
					success: function(data) {
						$(obj).remove();
						layer.msg(data.msg, {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							 
						}); 
					}
				})
			    layer.close(index);
			    
		  });
	}
	function take_order(id){
		layer.confirm('您确定收货？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type:"post",
				url: "{:url('member/take_order')}",
				data: {order_id : id},//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.reload();
						  }
					}); 
				}
			})
		})
	}
	
	function to_detail(id){
		location.href = "{:url('member/order_page')}?order_id="+id;
	}
	
</script>
